import * as echarts from 'echarts'

import chinaMapData from '../data/china'
console.log('数据是', chinaMapData)
echarts.registerMap('china', chinaMapData)
export function useEchart(el: HTMLElement) {
  const myChart = echarts.init(el)
  const updateSize = () => {
    myChart.resize()
  }
  const setOptions = (options: echarts.EChartsOption) => {
    myChart.setOption(options)
  }
  window.addEventListener('resize', () => {
    myChart.resize()
  })

  return {
    updateSize,
    setOptions,
    myChart
  }
}
